/**  
 * All rights Reserved, Designed By www.woniuxy.com
 * @Title:  Account.java   
 * @Package com.woniu.domain   
 * @Description:    Description  
 * @author: 蜗牛学院  
 * @date:   2019年8月29日 下午8:26:30
 * @user:   Administrator  
 * @version V1.0 
 * @Copyright: 2019 www.woniuxy.com Inc. All rights reserved. 
 * 注意：本内容仅限于成都蜗牛创想科技有限公司，禁止外泄以及用于其他的商业目
 */ 
package com.woniu.ssm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.woniu.ssm.domain.Book;
import com.woniu.ssm.mapper.BookMapper;
import com.woniu.ssm.util.PageBean;
import com.woniu.ssm.vo.Bookvo;
import com.woniu.ssm.vo.Queryvo;

/**
 * @author Administrator
 *
 */
@Service
@Transactional
public class BookServiceImpl implements BookService{
	@Autowired
	BookMapper bm;
	@Override
	public PageBean findList(Queryvo query) {
		PageBean pb = new PageBean();
		if(query != null) {
			if(query.getPageNow() == 0) {
				pb.setPageNow(0);
			}else {
				pb.setPageNow(query.getPageNow());
			}
		}
		List<Book> lists = bm.findBookList(query, pb);
		int count = bm.findCount(query);
		return new PageBean(pb.getPageNow(),count,lists);
	}
	@Override
	public void borrow(int uid, int bid) {
		bm.insertBorrow(uid,bid);
		bm.updateBorrow(bid);
	}
	@Override
	public List<Bookvo> findMyBook(int uid) {
		return bm.findMybook(uid);
	}
	@Override
	public void delBook(int bid) {
		bm.delBook(bid);
	}

}
